package com.ruoyi.reissue.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.reissue.domain.HrReissueCard;
import com.ruoyi.reissue.service.IHrReissueCardService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 补卡申请Controller
 * 
 * @author gy
 * @date 2025-05-20
 */
@RestController
@RequestMapping("/reissue/ReissueCard")
public class HrReissueCardController extends BaseController
{
    @Autowired
    private IHrReissueCardService hrReissueCardService;

    /**
     * 查询补卡申请列表
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrReissueCard hrReissueCard)
    {
        startPage();
        List<HrReissueCard> list = hrReissueCardService.selectHrReissueCardList(hrReissueCard);
        return getDataTable(list);
    }

    /**
     * 导出补卡申请列表
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:export')")
    @Log(title = "补卡申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrReissueCard hrReissueCard)
    {
        List<HrReissueCard> list = hrReissueCardService.selectHrReissueCardList(hrReissueCard);
        ExcelUtil<HrReissueCard> util = new ExcelUtil<HrReissueCard>(HrReissueCard.class);
        util.exportExcel(response, list, "补卡申请数据");
    }

    /**
     * 获取补卡申请详细信息
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hrReissueCardService.selectHrReissueCardById(id));
    }

    /**
     * 新增补卡申请
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:add')")
    @Log(title = "补卡申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrReissueCard hrReissueCard)
    {
        return toAjax(hrReissueCardService.insertHrReissueCard(hrReissueCard));
    }

    /**
     * 修改补卡申请
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:edit')")
    @Log(title = "补卡申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrReissueCard hrReissueCard)
    {
        return toAjax(hrReissueCardService.updateHrReissueCard(hrReissueCard));
    }

    /**
     * 删除补卡申请
     */
    @PreAuthorize("@ss.hasPermi('reissue:ReissueCard:remove')")
    @Log(title = "补卡申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hrReissueCardService.deleteHrReissueCardByIds(ids));
    }
}
